<?php
require_once ('Expression.php');

/**
 * @author wei.deng
 * @version 1.0
 * @created 05-八月-2011 11:04:55
 */
class VariableExpression extends Expression
{

	private $val;
	private $name;

	/**
	 * 
	 * @param name
	 * @param val
	 */
	public function __construct($name, $val = null)
	{
		$this->name = $name;
		$this->val = $val;
	}

	/**
	 * 
	 * @param context
	 */
	public function interpret(InterpreterContext $context)
	{
		if (!is_null($this->val)) {
			$context->replace($this, $this->val);
			$this->val = null;
		}
	}

	/**
	 * 
	 * @param value
	 */
	public function setValue($value)
	{
		$this->val = $value;
	}

	public function getKey()
	{
		return $this->name;
	}

}
?>